﻿let WebAppQueryIdMin = 0x1000;
let WebAppQueryIdMax = 0x1fff;
let WebAppQueryIdSeed = WebAppQueryIdMin;
function WebAppCallNative(callInfo) {
    return new Promise((resolve, reject) => {
        let queryId = WebAppQueryIdSeed;
        WebAppQueryIdSeed++;
        if (WebAppQueryIdSeed > WebAppQueryIdMax) {
            WebAppQueryIdSeed = WebAppQueryIdMin;
        }
        let callInfoJson = JSON.stringify(callInfo);
        //console.log("QueryId:"+queryId+",CallInfo:"+callInfoJson);
        WebAppQuery(queryId, callInfoJson, (queryId, callResultJson) => {
            //console.log("QueryId:" + queryId + ",CallResult:" + callResultJson);
            let callResult = JSON.parse(callResultJson);
            callResult.Value = JSON.parse(callResult.Value);
            resolve(callResult);
        });
    });
}